
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page contentType= "text/html;charset=utf-8" %>

<html>
<head><title>session count test</title></head>
<body>
    <h3>
      Counter :
      <%
        Integer counter = new Integer(1);
	HttpSession httpsession = request.getSession(true);
        if (httpsession.isNew()) {
                httpsession.setAttribute("count", counter);
                out.println(counter);
                System.out.println(counter);
        } else {
		//System.out.println(httpsession.getAttribute("count"));		
		
		if(httpsession.getAttribute("count") == null){ httpsession.setAttribute("count", 0); }
		
		Integer count = ((Integer) httpsession.getAttribute("count")).intValue();
                httpsession.setAttribute("count", new Integer(++count));
               	out.println(count);
		System.out.println(httpsession.getAttribute("count"));		
        }
      %>
      </h3>
</body>
</html>
